/**   
 * Copyright © 2019 eSunny Info. Tech Ltd. All rights reserved.
 * 
 * @Description:TODO(功能)
 * @className FileDaoImpl.java
 * @Package: com.erp.dao 
 * @author: yj   
 * @date: 2019年3月2日 下午2:23:37 
 */
package com.erp.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.erp.po.Files;

/**
 * @className FileDaoImpl.java
 * @author yj
 * @Description:TODO(功能)
 * @Date 2019年3月2日
 */
public class FileDaoImpl extends BaseDao implements FileDao {

	/* 
	 * 添加文件数据
	 */
	@Override
	public int insertFile(Connection conn, Files file) throws SQLException {
		String sql = "insert into files(id, file_name, file_desc, file_auto_name, user_name)\r\n" + 
				"       values(files_seq.nextval, ?, ?, ?, ?)";
		Object[] obj = {file.getFileName(), file.getFileDesc(), file.getFileAutoName(), file.getUserName()};
		return super.updateData(conn, sql, obj);
	}

	/* 
	 * 根据 userName 查询文件
	 */
	@Override
	public ResultSet selectFileByUserName(Connection conn, String userName) throws SQLException {
		String sql = "select * from files where user_name = ? ";
		return super.selectData(conn, sql, userName);
	}

	/* 
	 * 根据 id 查询文件
	 */
	@Override
	public ResultSet selectFileById(Connection conn, int id) throws SQLException {
		String sql = "select * from files where id = ? ";
		return super.selectData(conn, sql, id);
	}

	/* 
	 * 根据 id 删除文件数据
	 */
	@Override
	public int deleteFileById(Connection conn, int id) throws SQLException {
		String sql = "delete from files where id = ? ";
		return updateData(conn, sql, id);
	}

}
